﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    //Private Sub LongTask()

    private void LongTask()
    {

        for (int i = 0; i < 11; i++)
        {
            System.Threading.Thread.Sleep(1000);
            Session["State"] = i + 1;
        }
        Session["State"] = 100;


    }
    public static void OpenProgressBar(System.Web.UI.Page Page)
    {
        StringBuilder sbScript = new StringBuilder();

        sbScript.Append(" \n");
        Page.RegisterClientScriptBlock("OpenProgressBar", sbScript.ToString());
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Thread thread = new Thread(new ThreadStart(LongTask));
        thread.Start();

        Session["State"] = 1;
        OpenProgressBar(this.Page);
    }
}
